/***************************************************************************
 *   Copyright (C) 2007 by saa   *
 *   root@saa   *
 ***************************************************************************/

#ifndef MAINSTREAM_H
#define MAINSTREAM_H

#include "routeserver.h"
#include "singleton.h"

class MainWindow;

#define MS MainStream::instance()

class MainStream : public Singleton<MainStream>
{
    Q_OBJECT

    friend class Singleton<MainStream>;

    public:        
        ~MainStream();

    protected:
        MainStream();
        void timerEvent(QTimerEvent * event);
        void init();
        void initGUI();
        LogFlag::LogLevels m_logLevel;

        MainWindow * mainWindow;
        
    signals:
        void logProgrammeMessage(const QString & message, const LogFlag::LogLevels LogLevel = LogFlag::Common) const;
        void stop();
        void oneTracerouteFinished();
        void telnetClientFinished();
        void showLinks( const LinkList & linkList ) const;      
        void startNewSession();
        void linkList(const LinkList & linkList) const;

    public slots:
        void saveLinkList(const LinkList & linkList) const;
        void tracerouteToTargetStarted(const QString & routeServer, const QString & startedTarget);
        void tracerouteToTargetFinished(const QString & routeServer, const QString & finishedTarget);
        void log(const QString & message, const LogFlag::LogLevels = LogFlag::Common) const;
        void telnetClientFinished(QObject * sender);
        void setLogLevel(const LogFlag::LogLevels logLevel) {m_logLevel |= logLevel;}
        void start(const QList<RouteServer>&, const QStringList&);
        void stopAllThreads();
};

#endif
